package com.easy.service.impl;

import com.easy.bean.Member;
import com.easy.mapper.MemberDao;
import com.easy.service.MemberService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class MemberServiceImpl implements MemberService {
    @Autowired
    MemberDao memberDao;
    @Override
    public Member add(Member member) {
        //新增数据
        memberDao.add(member);
        //通过主键查询数据库中的数据
        Member result=memberDao.one(member.getId());
        return result;
    }

    @Override
    public int del(Integer id) {
        return memberDao.del(id);
    }

    @Override
    public Member edit(Member member) {
        memberDao.edit(member);
        Member result=memberDao.one(member.getId());
        return result;
    }

    @Override
    public List<Member> all(Member member) {
        return memberDao.all(member);
    }

    @Override
    public Member one(Integer id) {
        return memberDao.one(id);
    }

    public void page(Page page,Member member){
        int count=memberDao.pageCount(member);
        Object data=memberDao.page(page,member);
        page.setCount(count);
        page.setData(data);
    }
}
